﻿<cfsilent>
	<cfscript>
	
		event.setArg("pageTitle", "教学任务安排 - 通选课教学任务安排");

		sessionAdvice = getProperty("serviceFactory").getBean("sessionAdvice");
		depId = sessionAdvice.getUserProp("teacherDepartment");

		termID = event.getArg("TermID");
		academicYear = event.getArg("AcademicYear");
		academicTerm = event.getArg("AcademicTerm");
		
		limiteB2 = event.getArg("TASK.LIMITE.B2", 3);
		limiteS3 = event.getArg("TASK.LIMITE.S3", 1);

		currentTab = "labCourse";
		
		sql = "SELECT 
					institute_name 
				FROM 
					t_institute 
				WHERE 
					institute_id = :instituteId ";
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="instituteId", value=depId, cfsqltype="cf_sql_varchar" );
		rs_departmentEntity = queryObj.execute( sql=sql ).getResult(); 

		sql = "SELECT 
					a.cid, 
					a.course_name, 
					a.course_credit, 
					a.period_week, 
					a.period, 
					a.period_theory, 
					a.period_practice, 
					a.cat_id, 
					a.course_code, 
					(SELECT COUNT(*) FROM t_common_task WHERE t_common_task.term_id = :term AND a.cid = t_common_task.cid ) count 
				FROM 
					t_course a 
				WHERE 
					a.institute_id = :depID 
					AND 
					(a.cat_id = 'B2' OR a.cat_id = 'S3')
					AND 
					a.abandon = '0' 
				ORDER BY 
					a.cat_id, a.course_name ";
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="term", value=termID, cfsqltype="cf_sql_char" );
		queryObj.addParam( name="depID", value=depID, cfsqltype="cf_sql_varchar" );
		rs_course = queryObj.execute( sql=sql ).getResult(); 
		
		targetArgs = structNew();
	
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('DEFAULT_EVENT')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">教学任务安排</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 application"></i><cfif len(depID)><cfoutput>#rs_departmentEntity.institute_name# 通选课目录</cfoutput><cfelse>全校通选课教学任务</cfif>
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labCourse">class="active"</cfif> id="labCourse" tabTarget="Course">课程开设情况</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				<div id="Course" class="tabContent">
					
					<cfif rs_departmentEntity.recordCount>
						
						<cfset passArgs = structNew() />
						<cfset structInsert( passArgs, "DepID", depId, true) />
						<cfset structInsert( passArgs, "TID", termId, true) />
						
						<div class="noticeBlock">
							<div class="operation">
								<a class="uiButton uiButtonSpecial" href="<cfoutput>#buildURL('commonTaskDownloadExcel', passArgs)#</cfoutput>"><i class="mrs img btnDownload"></i><span class="uiButtonText">下载通选课教学任务</span></a>
							</div>
							<h3><cfoutput>#rs_departmentEntity.institute_name#</cfoutput></h3>
							<p><span class="img icon16x16 message"></span><em><cfoutput>#academicYear#</cfoutput>-<cfoutput>#academicTerm#</cfoutput></em>学期可开设全校通选课 <em><cfoutput>#rs_course.recordCount#</cfoutput></em> 门.</p>
							<hr/>
						</div>
					
					</cfif>
					
					<cfif rs_course.recordCount>
						<cfset structDelete(targetArgs, "DepID", false) />
						<cfset row = 0 />
						<table class="UIEditable">
							<thead>
								<tr>
									<td width="18"></td>
									<td>课程</td>
									<td width="100">课程号</td>
									<td width="25">学分</td>
									<td width="70">排课周学时</td>
									<td width="40">总学时</td>
									<td width="50">理论学时</td>
									<td width="50">实践学时</td>
									<td width="80">任务安排进度</td>
									<td width="18"></td>
								</tr>
							</thead>
							<tbody>
                                <cfloop query="rs_course">
									<cfset row++ />
									<cfset structInsert(targetArgs, "CID", rs_course.cid, true) />
									<tr class="editRows" rowid="<cfoutput>#rs_course.cid#</cfoutput>">
										<td class="index"><cfoutput>#row#</cfoutput></td>
										<td><cfoutput>#rs_course.course_name#</cfoutput></td>
										<td><span class="numeric"><cfoutput>#rs_course.course_code#</cfoutput></span></td>
										<td align="center"><span class="numeric"><cfoutput>#numberFormat(rs_course.course_credit, '_.__')#</cfoutput></span></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_course.period_week#</cfoutput></span></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_course.period#</cfoutput></span></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_course.period_theory#</cfoutput></span></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_course.period_practice#</cfoutput></span></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_course.count#</cfoutput> / <cfif rs_course.cat_id eq "S3"><cfoutput>#limiteS3#</cfoutput><cfelse><cfoutput>#limiteB2#</cfoutput></cfif></span></td>
										<td><a href="<cfoutput>#buildURL('commonTaskByCourse', targetArgs)#</cfoutput>" class="stat <cfif rs_course.count gt 0>running<cfelse>stop</cfif>"></a></td>
									</tr>
								</cfloop>
							</tbody>
						</table>
					</cfif>
					
				</div>
			
			</div>
		</li>
	</ul>
</div>